from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# 创建一个新的浏览器会话
driver = webdriver.Chrome()

# 设置超时时间为10秒
wait = WebDriverWait(driver, 10)

# 使用ExpectedConditions来等待元素存在并点击
element = wait.until(EC.presence_of_element_located((By.ID, "myElement")))  # 等待ID为"myElement"的元素出现
element.click()  # 点击该元素

# 使用VisibleToMouseClick等待元素可见并且可以被鼠标点击
wait.until(EC.visibility_of_element_located((By.NAME, "myButton")))  # 确保名为"myButton"的元素可见后可以被点击
driver.find_element_by_name("myButton").click()

# 关闭浏览器
driver.quit()